/**
 * 
 */
package com.massyframework.beanskin.launcher.scanning.maven;

import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import com.massyframework.beanskin.ModuleIdentifier;


/**
 * {@link LocalMavenProject},本地仓库中的Maven项目
 * @author huangkh
 *
 */
class LocalMavenProject extends MavenProject {
	
	private final List<URL> jarFiles;

	/**
	 * @param builder
	 */
	protected LocalMavenProject(Builder builder) {
		super(builder);
		List<URL> tmp = new ArrayList<>();
		tmp.add(Objects.requireNonNull(
				builder.jarURL, "\"jarURL\" cannot be null."));
		this.jarFiles =
				Collections.unmodifiableList(tmp);
	}

	@Override
	public List<URL> getOutputFiles(ModuleIdentifier identifier) {
		return this.jarFiles;
	}
	
	/**
	 * 创建构建器
	 * @return {@link Builder}
	 */
	public static Builder newBuilder() {
		return new Builder();
	}
	
	public static class Builder extends MavenProject.Builder {
		
		protected URL jarURL;
		
		/**
    	 * 设置项目坐标
    	 * @param coordinate {@link Coordinate}
    	 * @return {@link Builder}
    	 */
		@Override
    	public Builder coordinate(Coordinate coordinate) {
    		super.coordinate(coordinate);
    		return this;
    	}
		
		public Builder jarURL(URL jarFile) {
			this.jarURL = jarFile;
			return this;
		}
		
		public LocalMavenProject build() {
			return new LocalMavenProject(this);
		}
	}
}
